package com.bst.etl.factory.dbtype;


public class SqlserverTypeMapping implements ITypeMappingStrategy {
    @Override
    public String mapType(int columnType, int precision, int scale) {
        switch (columnType) {
            case java.sql.Types.BIT: return "BIT";
            case java.sql.Types.TINYINT: return "TINYINT";
            case java.sql.Types.SMALLINT: return "SMALLINT";
            case java.sql.Types.INTEGER: return "INT";
            case java.sql.Types.BIGINT: return "BIGINT";
            case java.sql.Types.FLOAT: return "FLOAT";
            case java.sql.Types.REAL: return "REAL";
            case java.sql.Types.DOUBLE: return "DOUBLE";
            case java.sql.Types.NUMERIC: return "DECIMAL(" + precision + "," + scale + ")";
            case java.sql.Types.DECIMAL: return "DECIMAL(" + precision + "," + scale + ")";
            case java.sql.Types.CHAR: return "CHAR(" + precision + ")";
            case java.sql.Types.VARCHAR: return "VARCHAR(" + precision + ")";
            case java.sql.Types.LONGVARCHAR: return "TEXT";
            case java.sql.Types.DATE: return "DATE";
            case java.sql.Types.TIME: return "TIME";
            case java.sql.Types.TIMESTAMP: return "DATETIME";
            case java.sql.Types.BINARY: return "BINARY(" + precision + ")";
            case java.sql.Types.VARBINARY: return "VARBINARY(" + precision + ")";
            case java.sql.Types.LONGVARBINARY: return "IMAGE";
            case java.sql.Types.BLOB: return "VARBINARY(MAX)";
            case java.sql.Types.CLOB: return "VARCHAR(MAX)";
            case java.sql.Types.BOOLEAN: return "BIT";
            case java.sql.Types.NCHAR: return "NCHAR(" + precision + ")";
            case java.sql.Types.NVARCHAR: return "NVARCHAR(" + precision + ")";
            case java.sql.Types.LONGNVARCHAR: return "NTEXT";
            case java.sql.Types.NCLOB: return "NVARCHAR(MAX)";
            default: return "VARCHAR(255)";
        }
    }

    @Override
    public String primaryKey() {
        return "ID INT IDENTITY(1,1) PRIMARY KEY,";
    }
}


